package com.ygj.meeting.action;

import static com.base.common.GlobaConstants.ACTION_RESULT_DATA;
import static com.base.common.GlobaConstants.ASYNCHRONOUS;
import static com.base.common.GlobaConstants.CONTENT_TYPE;
import static com.base.common.GlobaConstants.CONTENT_TYPE_JSON;
import static com.base.common.GlobaConstants.JSON;
import static com.base.common.GlobaConstants.ROOT;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.base.common.action.AbstractBaseAction;
import com.base.common.bean.ActionResult;
import com.base.common.entity.AnnualMeetingRecord;
import com.base.common.persistent.dao.MeetingSignRecordMapper;
import com.cjy.common.bean.OpAttributes;

@Action("annualMeetingAction")
@Results({ @Result(name = ASYNCHRONOUS, type = JSON, params = { ROOT,
		ACTION_RESULT_DATA, CONTENT_TYPE, CONTENT_TYPE_JSON }) })
public class AnnualMeetingAction extends AbstractBaseAction {

	private static final long serialVersionUID = 1L;

	private int meetingId;

	@Resource
	private MeetingSignRecordMapper meetingSignRecordMapper;
	public int getMeetingId() {
		return meetingId;
	}

	public void setMeetingId(int meetingId) {
		this.meetingId = meetingId;
	}

	/**
	 * 获取未在屏幕显示的年会签到记录
	 * 
	 * @return
	 */
	public String getUnCheckAnnualMeetingRecord() {
		try {
			List<AnnualMeetingRecord> annualMeetingRecords = new ArrayList<AnnualMeetingRecord>();
			annualMeetingRecords = meetingSignRecordMapper.queryEmployeeInfoByMeetingId(meetingId);
			for(AnnualMeetingRecord annualMeetingRecord : annualMeetingRecords){
				meetingSignRecordMapper.updateIsHavedShowByMeetingSignRecordId(annualMeetingRecord.getMeetingSignRecordId());
			}
			actionResult = ActionResult.getActionResult(new OpAttributes().add(
					"code", 1).add("result", annualMeetingRecords));
		} catch (Exception e) {
			e.printStackTrace();
			actionResult = ActionResult.getActionResult(new OpAttributes().add(
					"code", 0));
		}
		response.setHeader("Access-Control-Allow-Origin", "*");
		return returnType();
	}

}
